$(window).load(function(){
    var login_url="/OpenSwitch.cgi?method=auth&func=login&loginID="
    function loginFunc() {
        var username=$("#username").val();
        var password=$("#password").val();
        var form = document.forms["loginForm"]; //根据表单id获取表单对象
        var username = form.elements["username"].value; //获取用户名字段的值
        var password = form.elements["password"].value; //获取密码字段的值

        var timestamp=new Date().getTime();
        var loginID = username + timestamp;

        console.log("loginID： " + loginID);
        $.ajax({
            url:login_url + loginID,
            type:"post" ,
            data:{"username":username,"password":password},
            dataType:"json",
            success:function(data,dataTextStatus,jqxhr){ console.log("json:" + data);window.location.href="../index.html?loginID="+loginID; },
            error:function(jqxhr,textStatus,error) {$("#errormessage").text("用户名或密码错误");}
            })
    }
    $("#loginbtn").click(function(){
        loginFunc();
    })
})